﻿using System.Collections.ObjectModel;
using System.Xml.Serialization;
using ElectronicCommerce.Framework.Configuration.Attributes;

namespace ElectronicCommerce.Framework.Web.Configuration.Upload
{
    [ConfigFile("Upload.config")]
    [XmlRoot("UploadFileInfos")]
    public class UploadConfiguration
    {
        [XmlElement("FileInfo")]
        public UploadFileCollection UploadFileInfos
        {
            get;
            set;
        }
    }

    public class UploadFileCollection : KeyedCollection<UploadFileTypeEnum, UploadFileInfo>
    {
        protected override UploadFileTypeEnum GetKeyForItem(UploadFileInfo item)
        {
            return item.FileType;
        }
    }

    public class UploadFileInfo
    {
        [XmlAttribute("type")]
        public UploadFileTypeEnum FileType
        {
            get;
            set;
        }

        [XmlAttribute("folderName")]
        public string FolderName
        {
            get;
            set;
        }
    }
}
